﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Media.Imaging;

namespace Tanks
{
    public class Bonus
    {
        public BonusType Type { get; set; }

        Rectangle rect;
        Point position;
        public Rectangle Rect
        {
            get { return rect; }
        }

        public Bonus(BonusType bt,Point p)
        {
            Type = bt;
            position = p;
            draw();
        }

        void draw()
        {
            rect = new Rectangle();
            rect.Height = 50;
            rect.Width = 50;
            ((App)Application.Current).Main_canvas.Children.Add(rect);
            Canvas.SetTop(rect, position.Y);
            Canvas.SetLeft(rect, position.X);
            ImageBrush im_br = new ImageBrush();

            if (Type == BonusType.Rate)
                im_br.ImageSource = new BitmapImage(new Uri("/Tanks;component/Images/rate_small.jpg", UriKind.Relative));

            if (Type == BonusType.Speed_bullet)
                im_br.ImageSource = new BitmapImage(new Uri("/Tanks;component/Images/bullet_small.png", UriKind.Relative));

            if (Type == BonusType.Speed_tank)
                im_br.ImageSource = new BitmapImage(new Uri("/Tanks;component/Images/tank_speed_small.jpg", UriKind.Relative));

            if (Type == BonusType.Immortality)
                im_br.ImageSource = new BitmapImage(new Uri("/Tanks;component/Images/immortality_small.jpg", UriKind.Relative));

            if (Type == BonusType.Invisibility)
                im_br.ImageSource = new BitmapImage(new Uri("/Tanks;component/Images/invisibility_small.jpg", UriKind.Relative));

            im_br.Stretch = Stretch.UniformToFill;
            rect.Fill = im_br;
        }
    }
}
